Skip to content

[CI] Fix CI script test subprocess environment#19713

Merged
tqchen merged 1 commit into
apache:mainfrom
tlopex:fix-ci-git-utils-annotations
Jun 10, 2026
Merged

[CI] Fix CI script test subprocess environment#19713
tqchen merged 1 commit into
apache:mainfrom
tlopex:fix-ci-git-utils-annotations

Conversation

@tlopex

@tlopex tlopex commented Jun 10, 2026

Copy link
Copy Markdown
Member

This fixes CI script tests that accidentally run helper scripts with the wrong Python interpreter.

Some tests call run_script(..., env={...}) to pass test-specific environment variables. subprocess.run treats env as a full environment replacement, so the subprocess lost the current PATH. Since these scripts use a shebang like:

#!/usr/bin/env python3

they could fall back to the system Python instead of the active test Python.

In the wheel test environment this caused the CI helper scripts to run under Python 3.8, even though TVM requires Python >=3.10. Importing ci/scripts/jenkins/git_utils.py then failed on PEP 604 annotations such as:

Any | None
tuple[str, str] | None

with:

TypeError: unsupported operand type(s) for |: '_SpecialForm' and 'NoneType'

This patch updates tests/python/ci/test_utils.py::run_script to merge test-provided environment variables into os.environ instead of replacing the entire environment. This preserves the active Python/PATH while still allowing each test to override or add variables.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@tqchen tqchen merged commit 795cd2d into apache:main Jun 10, 2026
9 checks passed
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
This fixes CI script tests that accidentally run helper scripts with the
wrong Python interpreter.

Some tests call `run_script(..., env={...})` to pass test-specific
environment variables. `subprocess.run` treats `env` as a full
environment replacement, so the subprocess lost the current `PATH`.
Since these scripts use a shebang like:

```python
#!/usr/bin/env python3
```

they could fall back to the system Python instead of the active test
Python.

In the wheel test environment this caused the CI helper scripts to run
under Python 3.8, even though TVM requires Python >=3.10. Importing
`ci/scripts/jenkins/git_utils.py` then failed on PEP 604 annotations
such as:

```python
Any | None
tuple[str, str] | None
```

with:

```text
TypeError: unsupported operand type(s) for |: '_SpecialForm' and 'NoneType'
```

This patch updates `tests/python/ci/test_utils.py::run_script` to merge
test-provided environment variables into `os.environ` instead of
replacing the entire environment. This preserves the active Python/PATH
while still allowing each test to override or add variables.

(cherry picked from commit 795cd2d)
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
This fixes CI script tests that accidentally run helper scripts with the
wrong Python interpreter.

Some tests call `run_script(..., env={...})` to pass test-specific
environment variables. `subprocess.run` treats `env` as a full
environment replacement, so the subprocess lost the current `PATH`.
Since these scripts use a shebang like:

```python
#!/usr/bin/env python3
```

they could fall back to the system Python instead of the active test
Python.

In the wheel test environment this caused the CI helper scripts to run
under Python 3.8, even though TVM requires Python >=3.10. Importing
`ci/scripts/jenkins/git_utils.py` then failed on PEP 604 annotations
such as:

```python
Any | None
tuple[str, str] | None
```

with:

```text
TypeError: unsupported operand type(s) for |: '_SpecialForm' and 'NoneType'
```

This patch updates `tests/python/ci/test_utils.py::run_script` to merge
test-provided environment variables into `os.environ` instead of
replacing the entire environment. This preserves the active Python/PATH
while still allowing each test to override or add variables.

(cherry picked from commit 795cd2d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants